-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIT: boost inlining when callee unboxes an arg #110596
Conversation
Especially so if the caller is passing an exact type. This may lead to the JIT being able to stack allocate the box and promote the underlying payload. Fixes dotnet#104479
On the example from #104479: ; Method Program:<<Main>$>g__BoxTest|0_0():int (FullOpts)
G_M15828_IG01: ;; offset=0x0000
sub rsp, 40
;; size=4 bbWeight=1 PerfScore 0.25
G_M15828_IG02: ;; offset=0x0004
mov ecx, 42
call [System.Number:Int32ToDecStr(int):System.String]
mov rdx, rax
mov rcx, 0x7FFC28EF66C0 ; Program:<<Main>$>g__Consume|0_2[System.String](System.String)
call [Program:<<Main>$>g__Consume|0_2[System.__Canon](System.__Canon)]
mov eax, 42
;; size=35 bbWeight=1 PerfScore 7.00
G_M15828_IG03: ;; offset=0x0027
add rsp, 40
ret
;; size=5 bbWeight=1 PerfScore 1.25
; Total bytes of code: 4 SPMI sees some diffs and quite a few missed contexts. MihuBot did not see many diffs, however:
So we may need a bespoke SPMI to really evaluate the imapact here. |
@hez2010 FYI -- seems quite easy to blow code up this way, but perhaps worth considering. |
@EgorBo FYI |
@@ -1716,6 +1724,30 @@ double ExtendedDefaultPolicy::DetermineMultiplier() | |||
JITDUMP("\nPrejit root candidate has arg that feeds a conditional. Multiplier increased to %g.", multiplier); | |||
} | |||
|
|||
if (m_ArgUnboxExact > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndyAyersMS I think you can also rely on existing m_ArgIsBoxedAtCallsite
here, so if an arg is boxed on the callsite and unboxed in the callee - it should be quite profitable.
UPD: although, probably not - m_ArgIsBoxedAtCallsite
alone is not telling which arg exactly is boxed 🙂
At least from MihuBot I only see more inlining, and no cases where we removed allocations. But might as well see if the lab spots anything. |
Especially so if the caller is passing an exact type. This may lead to the JIT being able to stack allocate the box and promote the underlying payload.
Fixes #104479